<%@ page language="java"
	import="java.util.*"
	pageEncoding="UTF-8"%>
<%@page import="com.tjsinfo.tjsoa.meetingroom.vo.MeetingRoomEmploy"%>
<%@page import="com.tjsinfo.tjsoa.system.vo.User"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
		 	+ path + "/";
	User user = (User)session.getAttribute("user");
    String userId=String.valueOf(user.getUser_id());
	List reUseList=(List)request.getAttribute("reUseList");
	String time=(String)request.getAttribute("time");
	String year=(String)request.getAttribute("year");
	String month=(String)request.getAttribute("month");
	String roomId=(String)request.getAttribute("roomId");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<html:base />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>天津市粮油集团有限公司</title>
		<style>
#container {
	width: 600px;
	height: 300px;
	border: 3px solid #c3daf9;
}

.calendar {
	background-image: url(<%=basePath%>images/icon_64.gif) !important;
}

.blist {
	background-image: url(<%=basePath%>images/icon_64.gif) !important;
}

.bmenu {
	background-image: url(<%=basePath%>images/ju.gif) !important;
}

.menu-title {
	background: #ebeadb url(<%=basePath%>images/icon_64.gif) repeat-x;
	border-bottom: 1px solid #99bbe8;
	color: #15428b;
	font: bold 10px tahoma, arial, verdana, sans-serif;
	display: block;
	padding: 3px;
}

.lan01 {
	background: url(<%=basePath%>images/lanbg01.gif) no-repeat 0 0;
	width: 6px;
	height: 24px;
}

.lan02 {
	background: url(<%=basePath%>images/lanbg02.gif) repeat-x;
	width: 99%;
	height: 24px;
}

.lan03 {
	background: url(<%=basePath%>images/lanbg03.gif) no-repeat;
	width: 8px;
	height: 24px;
}

.cha {
	padding-top: 3px
}
</style>
		<link href="<%=basePath%>style/txlz7.css" rel="stylesheet" type="text/css" />
		<link href="<%=basePath %>ajaxFramework/ext-2.1/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
	    <script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/ext-all.js"></script>
	    <script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/source/locale/ext-lang-zh_CN.js"></script>
	    
		<script type='text/javascript' src='<%=basePath%>dwr/interface/MeetingRoomEmployBo.js'></script>
		<script type='text/javascript' src="<%=basePath%>dwr/engine.js"></script>
		<script type='text/javascript' src="<%=basePath%>dwr/util.js"></script>
        <script>
		function back()
	   {
		   history.back(-1);
	   }
		function deletefrom(id)
	    {
	       document.form1.id.value = id;
			Ext.MessageBox.confirm('提示框', '您确认删除此会议室信息？', function(btn){
				if(btn=='yes'){
					deleteWorkSummary();
				}
			});
	    }
		function deleteWorkSummary()
	    {
		   var form1 =  document.getElementById('form1');
		   form1.setAttribute('action','<%=basePath%>tjsinfo/tjsoa/meetingroom/copyDelete.do');
		   document.form1.submit();
	    }
	    
   	   function isTrueDate(time){
          MeetingRoomEmployBo.isTrueDate(time,isTrueDateAfter);
      }
	  function isTrueDateAfter(data){
	         if(data)
	    	{
	    	   window.location.href='<%=basePath%>tjsinfo/tjsoa/meetingroom/newRoomEmpoly.do?time=<%=time %>&year=<%=year %>&month=<%=month %>&roomId=<%=roomId %>';
	    	}
		     else
	    	{
			   Ext.MessageBox.alert('提示框','<nobr>已超过预定日期,无法预定</nobr>');
	    	   return;	
	    	}
		}
		
	  function isUpdate(id,userId){
          MeetingRoomEmployBo.isApplicationUser(id,userId,{
		  callback:function(data) {
			if(data)
		    	 {
		    		window.location.href='<%=basePath%>tjsinfo/tjsoa/meetingroom/copyUpdate.do?&id='+id+'';
		    	 }
			else
		    	 {
				  Ext.MessageBox.alert('提示框','<nobr>您不是申请人，无法修改</nobr>');
				  return;
			 } 
		}
	  });
      }
       function isDelete(id,userId){
          MeetingRoomEmployBo.isApplicationUser(id,userId,{
          callback:function(data){
             if(data)
		    	{
		    	   deletefrom(id);
		    	}
		     else
		    	{
				   Ext.MessageBox.alert('提示框','<nobr>您不是申请人，无法删除</nobr>');
		    	   return;	
		    	}
          }
          });
      }
      window.onload = function(){
		document.getElementById("right").style.height = document.body.clientHeight;
		document.getElementById("tableid").style.height = document.body.clientHeight-60;
		var tb = new Ext.Toolbar(
			{
				height:25
			}
		);
	
	    tb.render('menu');
		tb.add(
		{
	            text:'申请会议室',
	            iconCls: 'daohang',
	        	handler: function(){
	        		location.href="<%=basePath%>tjsinfo/tjsoa/meetingroom/newRoomEmpoly.do?time=<%=time %>&year=<%=year %>&month=<%=month %>&roomId=<%=roomId %>";
				}
	    },
	    {
	            text:'返回',
	            iconCls: 'daohang',
	        	handler: function(){
	        		back();
				}
	    }
	    );
		tb.addFill();
	    tb.addText('<img id="windowResize" src="<%=basePath%>images/m_icon05.gif;"><a style="font-weight:bold; color:black;line-height: 22px;">会议申请</a>&nbsp;&nbsp;&nbsp;');
	}
		</script>
	</head>
	<body>
			<div id="right">
				<div id="menu" style="padding-top:4px;"></div>
				<table width="100%" border="0" cellspacing="0" cellpadding="0"  id="tableid">
					<tr>
						<td width="100%" valign="top" height="100%">
							<div class="contabwd" id="Empolylist">
								<table class="p_06" width="100%" border="0" cellspacing="0">
									<tr>
										<th width="8%" style="text-align: center">
											申请日期
										</th>
										<th width="8%" style="text-align: center">
											申请人

										</th>
										<th width="12%" style="text-align: center">
											会议名称
										</th>
										<th width="12%" style="text-align: center">
											计划开始时间

										</th>
										<th width="12%" style="text-align: center">
											持续时间
										</th>
										<th width="12%" style="text-align: center">
											会议室名称

										</th>
										<th width="16%" style="text-align: center">
											地点
										</th>
										<th width="7%" style="text-align: center">
											状态

										</th>
										<th width="8%" style="text-align: center">
											操作
										</th>
									</tr>
									<%
										SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
										int a = 1;
										for (Iterator iterator = reUseList.iterator(); iterator.hasNext();) {
											MeetingRoomEmploy mre = (MeetingRoomEmploy) iterator.next();
											String name = mre.getMeetingName();
											if(mre.getMeetingName().length()>8)mre.setMeetingName(name.substring(0,8));
											String roomName = mre.getMeetingRoomMain().getMeetingroomName();
											if(mre.getMeetingRoomMain().getMeetingroomName().length()>7)mre.getMeetingRoomMain().setMeetingroomName(roomName.substring(0,7));
											String place = mre.getMeetingRoomMain().getPlace();
											if(mre.getMeetingRoomMain().getPlace().length()>13)mre.getMeetingRoomMain().setPlace(place.substring(0,13));
											if (a % 2 == 0) {
									%>
									<tr bgcolor="#F4F4F4">
										<td><%=mre.getEmpolyTime() %></td>
										<td><%=mre.getExamineUserName() %></td>
										<td><a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/openArrangements.do?&id=<%=mre.getId() %>"><%=mre.getMeetingName() %></a></td>
										<td><%=sdf.format(mre.getStartTime()) %></td>
										<td><%=mre.getEndTime() %>小时</td>
										<td><a title="<%=roomName %>"><%=mre.getMeetingRoomMain().getMeetingroomName() %></a></td>
										<td><a title="<%=place %>"><%=mre.getMeetingRoomMain().getPlace() %></a></td>
										<%if("1".equals(mre.getState())){ %>
										<td>已预定</td>
										<td><a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/openArrangements.do?&id=<%=mre.getId() %>">查看</a></td>
										<%}else if("2".equals(mre.getState())){ %>
										<td>已使用</td>
										<td><a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/openArrangements.do?&id=<%=mre.getId() %>">查看</a></td>
										<%}else if("3".equals(mre.getState())){
											String str = String.valueOf(user.getUser_id());
										%>
											<td>待审批</td>
											<td>
											<%
											if(str.equals(mre.getApplicationUserId())){%>
												<a href="javascript:isUpdate('<%=mre.getId()%>',<%=userId %>)">修改</a>|
												<a href="javascript:isDelete('<%=mre.getId()%>',<%=userId %>)">删除</a>
											<%}else{%>
												<a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/openArrangements.do?&id=<%=mre.getId() %>">查看</a>
											<%} %>
											</td>
										<%}else if("0".equals(mre.getState())){ %>
											<td>未通过</td>
											<td>
												<a href="javascript:isUpdate('<%=mre.getId()%>',<%=userId %>)">修改</a>|
												<a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/openArrangements.do?&id=<%=mre.getId() %>">查看</a>
											</td>
										<%} %>
									</tr>
									<%
										} else {
									%>
									<tr>
										<td><%=mre.getEmpolyTime() %></td>
										<td><%=mre.getExamineUserName() %></td>
										<td><a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/openArrangements.do?&id=<%=mre.getId() %>"><%=mre.getMeetingName() %></a></td>
										<td><%=sdf.format(mre.getStartTime()) %></td>
										<td><%=mre.getEndTime() %>小时</td>
										<td><a title="<%=roomName %>"><%=mre.getMeetingRoomMain().getMeetingroomName() %></a></td>
										<td><a title="<%=place %>"><%=mre.getMeetingRoomMain().getPlace() %></a></td>
										<%if("1".equals(mre.getState())){ %>
										<td>已预定</td>
										<td><a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/openArrangements.do?&id=<%=mre.getId() %>">查看</a></td>
										<%}else if("2".equals(mre.getState())){ %>
										<td>已使用</td>
										<td><a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/openArrangements.do?&id=<%=mre.getId() %>">查看</a></td>
										<%}else if("3".equals(mre.getState())){
											String str = String.valueOf(user.getUser_id());
										%>
											<td>待审批</td>
											<td>
											<%
											if(str.equals(mre.getApplicationUserId())){%>
												<a href="javascript:isUpdate('<%=mre.getId()%>',<%=userId %>)">修改</a>|
												<a href="javascript:isDelete('<%=mre.getId()%>',<%=userId %>)">删除</a>
											<%}else{%>
												<a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/openArrangements.do?&id=<%=mre.getId() %>">查看</a>
											<%} %>
											</td>
										<%}else if("0".equals(mre.getState())){ %>
											<td>未通过</td>
											<td>
												<a href="javascript:isUpdate('<%=mre.getId()%>',<%=userId %>)">修改</a>|
												<a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/openArrangements.do?&id=<%=mre.getId() %>">查看</a></td>
										<%} %>
									</tr>
									<%
										}
											a++;
										}
									%>
									<tr align="center">
									 <td colspan="9" style="border-bottom: 1px #d0d0d0 solid"><div class="page01"></div></td>
									</tr>
								</table>
							</div>
						
						</td>
					</tr>
				</table>
			</div>
		<form name="form1" method="post" id="form1">
			<input type="hidden" name="id" value="" />
			<input type="hidden" name="time" value="<%=time%>" />
	    </form>
	</body>
</html>
		